package info.niwota.web.proxy;

import java.io.IOException;
import java.net.Socket;

import x.org.apache.http.impl.DefaultHttpServerConnection;
import x.org.apache.http.impl.io.SocketInputBuffer;
import x.org.apache.http.impl.io.SocketOutputBuffer;
import x.org.apache.http.io.SessionInputBuffer;
import x.org.apache.http.io.SessionOutputBuffer;
import x.org.apache.http.params.HttpParams;

public class ProxyHttpServerConnection extends DefaultHttpServerConnection {


	private boolean tunneling = false;

	private SocketOutputBuffer out;

	private SocketInputBuffer in;

	public SocketOutputBuffer getOut() {
		return out;
	}

	public SocketInputBuffer getIn() {
		return in;
	}

	@Override
	protected SessionInputBuffer createSessionInputBuffer(Socket socket,
			int buffersize, HttpParams params) throws IOException {
		in = new SocketInputBuffer(socket, buffersize, params);
		return in;
	}

	@Override
	protected SessionOutputBuffer createSessionOutputBuffer(Socket socket,
			int buffersize, HttpParams params) throws IOException {
		out = new SocketOutputBuffer(socket, buffersize, params);
		return out;
	}

	@Override
	public Socket getSocket() {
		return super.getSocket();
	}

	@Override
	public void bind(Socket socket, HttpParams params) throws IOException {
		super.bind(socket, params);
	}

	public void setTunneling(boolean b) {
		this.tunneling = b;
	}

	public boolean isTunneling() {
		return this.tunneling;
	}

}
